<?php

if (defined('NO_DIRECT')) {
	if (isset($_GET['i'])) { // id orang itu
		$user = false;
		if ($session['user']['user_id'] == $_GET['i']) {
			$user = $session['user'];
		} else {
			$user = db_result('SELECT * FROM users WHERE user_id = '.intval($_GET['i']));
		}
		if ($user === false) {
			// user not found
			echo 'user not found';
		} else {
			$post = get_posts($user['user_id']);
			$following = get_followings($user['user_id']);
			$follower = get_followers($user['user_id']);
			if ($session['user']['user_id'] == $_GET['i']) {
				$his_post = $post;
				$his_following = $following;
				$his_follower = $follower;
			} else {
				$his_post = get_posts(intval($_GET['i']));
				$his_following = get_followings(intval($_GET['i']));
				$his_follower = get_followers(intval($_GET['i']));
			}
			?>
			<p>
			@<?php echo $user['username']; ?> - <?php echo $user['name']; ?><br />
			<?php echo $post['count']; ?> post<br />
			<?php echo $following['count']; ?> following<br />
			<?php echo $follower['count']; ?> followers<br />
			<?php echo $user['email']; ?>
			</p>
			<?php
		}
	}
}
